Skip to content

fix(mcpx): bound provider response-body reads (#4354) - #6771

Merged
dezren39 merged 1 commit into
mainfrom
queue/4354-provider-body-cap
Nov 7, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/4354-provider-body-cap

Conversation

@dezren39

@dezren39 dezren39 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Fix

Both OpenAI-compatible providers (internal/model Generate, internal/scripting Complete) buffered whole response bodies with io.ReadAll and embedded whole error bodies in the returned error (#4354, reproduced at 8 MiB+ by lane code-f's triage probe).

  • Error path: body read through io.LimitReader(resp.Body, defaults.HTTPErrorBodyLimit) (4KB, the existing house bound used by mcpclient) before being formatted into the error.
  • Success path: body read through a new cap, defaults.ProviderResponseBodyLimit (upstream.responseBodyLimit: 8MiB in defaults.json, plumbed through the defaults struct/var per the constants-in-defaults guard). Over-cap bodies refuse with an error naming the provider and the byte limit — never a silent truncation that surfaces as a JSON parse failure.

Tests

6 new regression tests (provider_body_limit_test.go in both packages; oracle = the produced error's length and text):

  • Oversized error body (1 MiB) → error length ≤ cap + overhead, still names HTTP 500.
  • Oversized success body (cap+1) → refusal naming provider + cap; not a JSON error.
  • Small error body → passes through exactly as before.

go test ./internal/model/ ./internal/scripting/ -count=1 green on the laptop. Note: internal/defaults has one pre-existing failure on clean main (TestNoPackageRedeclaresADefault over a literal timeout in internal/preflight/resolve.go:422, stash-verified unrelated to this change).

Cross-repo: dezren39/darwin-nix carries no vendored mcpx Go source (established on #5742); the fix propagates via the package pin.

Closes #4354.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 7, 2026 04:30
@coderabbitai

coderabbitai Bot commented Nov 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cf721c6b-b3d2-408d-b12e-5501161a70e5
Commits

Reviewing files that changed from the base of the PR and between 65bc307 and 4564965.

Files selected for processing: 6

  • pkgs/mcpx/internal/defaults/defaults.go
  • pkgs/mcpx/internal/defaults/defaults.json
  • pkgs/mcpx/internal/model/openai.go
  • pkgs/mcpx/internal/model/provider_body_limit_test.go
  • pkgs/mcpx/internal/scripting/provider.go
  • pkgs/mcpx/internal/scripting/provider_body_limit_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T04:31:44.617592Z 4564965 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant